Conversation
1. 新增相关状态变量防止重复触发沉船心情扣减 2. 调整结算超时处理逻辑,避免误触扣心情和点击 3. 规范沉船判定和心情扣减的触发时机
## 由 Sourcery 提供的摘要 调整自动搜查战斗结算逻辑,以正确区分已确认的沉船损失与暂时匹配到的 D 评价战斗,并优化 SP 关卡通关判定条件。 错误修复: - 防止在未出现沉船确认弹窗时,将自动搜查战斗误判为 D 评价撤退。 - 确保在结果识别过程中,S/A/B 评价结果可以覆盖暂时匹配到的 D 评价模板。 - 修复联合舰队 SP 关卡的通关逻辑,使只有已确认的 S 评价结算才计为通关,而 A/B/C/D 评价会继续出击。 - 通过记录士气已被扣减的状态,避免在沉船时重复扣减士气。 功能改进: - 在联合自沉战斗中显式记录 S 评价结果,以支持精确的 SP 通关判定。 - 将 D 评价的沉船确认和士气扣减集中到自动搜查战斗状态阶段统一处理,使逻辑更加稳健。 <details> <summary>Original summary in English</summary> ## Summary by Sourcery Adjust automatic search combat settlement handling to correctly distinguish confirmed shipwreck losses from transient D-rank matches and refine SP stage clear conditions. Bug Fixes: - Prevent misclassifying auto-search battles as D-rank retreats unless a shipwreck confirmation popup appears. - Ensure S/A/B rank results can override transiently matched D-rank templates during result recognition. - Fix coalition SP stage clear logic so only confirmed S-rank settlements count as clears, with A/B/C/D ranks continuing sorties. - Avoid duplicate morale reduction on shipwreck by tracking whether the reduction has already been applied. Enhancements: - Record S-rank results explicitly in coalition scuttle battles to support precise SP clear determination. - Centralize D-rank shipwreck confirmation and morale reduction in the auto-search combat status phase for more robust handling. </details> Bug 修复: - 在自动索敌战斗中,只有在出现沉船确认弹窗后才将战斗视为沉船,避免误判为 D 评价撤退。 - 确保在战斗结果识别过程中,S/A/B 评价可以覆盖临时匹配到的 D 评价模板。 - 修复联合舰队 SP 关卡通关逻辑,只有确认的 S 评价结算才视为通关,而 A/B/C/D 评价会触发继续出击。 增强: - 在联合拆解战中显式记录 S 评价结果,以支持更精确的 SP 通关判定。 <details> <summary>Original summary in English</summary> ## 由 Sourcery 提供的摘要 调整自动搜查战斗结算逻辑,以正确区分已确认的沉船损失与暂时匹配到的 D 评价战斗,并优化 SP 关卡通关判定条件。 错误修复: - 防止在未出现沉船确认弹窗时,将自动搜查战斗误判为 D 评价撤退。 - 确保在结果识别过程中,S/A/B 评价结果可以覆盖暂时匹配到的 D 评价模板。 - 修复联合舰队 SP 关卡的通关逻辑,使只有已确认的 S 评价结算才计为通关,而 A/B/C/D 评价会继续出击。 - 通过记录士气已被扣减的状态,避免在沉船时重复扣减士气。 功能改进: - 在联合自沉战斗中显式记录 S 评价结果,以支持精确的 SP 通关判定。 - 将 D 评价的沉船确认和士气扣减集中到自动搜查战斗状态阶段统一处理,使逻辑更加稳健。 <details> <summary>Original summary in English</summary> ## Summary by Sourcery Adjust automatic search combat settlement handling to correctly distinguish confirmed shipwreck losses from transient D-rank matches and refine SP stage clear conditions. Bug Fixes: - Prevent misclassifying auto-search battles as D-rank retreats unless a shipwreck confirmation popup appears. - Ensure S/A/B rank results can override transiently matched D-rank templates during result recognition. - Fix coalition SP stage clear logic so only confirmed S-rank settlements count as clears, with A/B/C/D ranks continuing sorties. - Avoid duplicate morale reduction on shipwreck by tracking whether the reduction has already been applied. Enhancements: - Record S-rank results explicitly in coalition scuttle battles to support precise SP clear determination. - Centralize D-rank shipwreck confirmation and morale reduction in the auto-search combat status phase for more robust handling. </details> </details>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's Guide优化自动搜索战斗中沉船心情值减少和SP清零判定逻辑,避免重复或误判导致的心情惩罚;同时将由 uv 管理的 Python 查找与校验逻辑泛化为支持任意已安装的 CPython 3.x,而不是固定绑定到 3.14.3 版本。 更新后的自动搜索战斗沉船心情减少时序图sequenceDiagram
participant AutoSearchCombat
participant Emotion
AutoSearchCombat->>AutoSearchCombat: auto_search_combat(emotion_reduce, fleet_index)
AutoSearchCombat->>AutoSearchCombat: set _auto_search_emotion_reduce
AutoSearchCombat->>AutoSearchCombat: set _auto_search_fleet_index
AutoSearchCombat->>AutoSearchCombat: set _shipwreck_emotion_reduced = False
AutoSearchCombat->>AutoSearchCombat: auto_search_combat_execute(emotion_reduce, fleet_index)
alt appear(OPTS_INFO_D) in auto_search_combat_execute
alt emotion_reduce and not _shipwreck_emotion_reduced
AutoSearchCombat->>Emotion: reduce(fleet_index, shipwreck=True)
AutoSearchCombat->>AutoSearchCombat: _shipwreck_emotion_reduced = True
end
AutoSearchCombat->>AutoSearchCombat: _withdraw = True
else appear(BATTLE_STATUS_D or EXP_INFO_D)
AutoSearchCombat->>AutoSearchCombat: break loop (no emotion change)
else confirm_timer.reached()
AutoSearchCombat->>AutoSearchCombat: _withdraw = True (no emotion change)
end
AutoSearchCombat->>AutoSearchCombat: auto_search_combat_status()
AutoSearchCombat->>AutoSearchCombat: handle_battle_status()
AutoSearchCombat->>AutoSearchCombat: handle_exp_info()
alt appear(OPTS_INFO_D) in auto_search_combat_status
alt _auto_search_emotion_reduce and not _shipwreck_emotion_reduced
AutoSearchCombat->>Emotion: reduce(_auto_search_fleet_index, shipwreck=True)
AutoSearchCombat->>AutoSearchCombat: _shipwreck_emotion_reduced = True
end
AutoSearchCombat->>AutoSearchCombat: _withdraw = True
end
泛化的 uv 管理 Python 查找与环境设置流程图flowchart TD
A[Start _ensure_self_contained_python] --> B{_venv_python_works and _managed_python_executable}
B -->|yes| C[Return]
B -->|no| D[_uv_python_env]
D --> E{_managed_python_executable}
E -->|no| F[Run uv python install --managed-python]
F --> G[_managed_python_executable]
E -->|yes| G
G --> H[Run uv python find --managed-python]
subgraph ManagedPythonSelection
I[venv_python_install_dir]
I --> J[glob cpython-*-* sorted reverse]
J --> K{python.exe or bin/python3 or bin/python}
end
H --> L[End]
文件级变更
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideRefines auto-search combat emotion reduction and SP-clear evaluation logic to avoid duplicate or false-positive mood penalties, while generalizing the uv-managed Python discovery and validation to work with any installed CPython 3.x rather than a fixed 3.14.3 version. Sequence diagram for updated auto-search combat shipwreck emotion reductionsequenceDiagram
participant AutoSearchCombat
participant Emotion
AutoSearchCombat->>AutoSearchCombat: auto_search_combat(emotion_reduce, fleet_index)
AutoSearchCombat->>AutoSearchCombat: set _auto_search_emotion_reduce
AutoSearchCombat->>AutoSearchCombat: set _auto_search_fleet_index
AutoSearchCombat->>AutoSearchCombat: set _shipwreck_emotion_reduced = False
AutoSearchCombat->>AutoSearchCombat: auto_search_combat_execute(emotion_reduce, fleet_index)
alt appear(OPTS_INFO_D) in auto_search_combat_execute
alt emotion_reduce and not _shipwreck_emotion_reduced
AutoSearchCombat->>Emotion: reduce(fleet_index, shipwreck=True)
AutoSearchCombat->>AutoSearchCombat: _shipwreck_emotion_reduced = True
end
AutoSearchCombat->>AutoSearchCombat: _withdraw = True
else appear(BATTLE_STATUS_D or EXP_INFO_D)
AutoSearchCombat->>AutoSearchCombat: break loop (no emotion change)
else confirm_timer.reached()
AutoSearchCombat->>AutoSearchCombat: _withdraw = True (no emotion change)
end
AutoSearchCombat->>AutoSearchCombat: auto_search_combat_status()
AutoSearchCombat->>AutoSearchCombat: handle_battle_status()
AutoSearchCombat->>AutoSearchCombat: handle_exp_info()
alt appear(OPTS_INFO_D) in auto_search_combat_status
alt _auto_search_emotion_reduce and not _shipwreck_emotion_reduced
AutoSearchCombat->>Emotion: reduce(_auto_search_fleet_index, shipwreck=True)
AutoSearchCombat->>AutoSearchCombat: _shipwreck_emotion_reduced = True
end
AutoSearchCombat->>AutoSearchCombat: _withdraw = True
end
Flow diagram for generalized uv-managed Python discovery and setupflowchart TD
A[Start _ensure_self_contained_python] --> B{_venv_python_works and _managed_python_executable}
B -->|yes| C[Return]
B -->|no| D[_uv_python_env]
D --> E{_managed_python_executable}
E -->|no| F[Run uv python install --managed-python]
F --> G[_managed_python_executable]
E -->|yes| G
G --> H[Run uv python find --managed-python]
subgraph ManagedPythonSelection
I[venv_python_install_dir]
I --> J[glob cpython-*-* sorted reverse]
J --> K{python.exe or bin/python3 or bin/python}
end
H --> L[End]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些高层次的反馈:
- 在
CoalitionScuttleCombat中,当is_auto_search_running()为 true 时就会设置_is_s_rank,但这并不能真正保证是 S 评价结果;建议仅在检测到确认的 S/EXP_INFO_S 时才设置_is_s_rank,以免 SP 完成逻辑把非 S 的战斗误判为通过。 AutoSearchCombat上新增的_auto_search_emotion_reduce、_auto_search_fleet_index和_shipwreck_emotion_reduced标志是类属性,会在实例之间共享;如果自动周回流程可能并发运行或被复用,建议把这些改为实例属性,以避免不同运行之间的状态泄漏。
给 AI 代理的提示
请处理这次代码评审中的所有评论:
## 整体评论
- 在 `CoalitionScuttleCombat` 中,当 `is_auto_search_running()` 为 true 时就会设置 `_is_s_rank`,但这并不能真正保证是 S 评价结果;建议仅在检测到确认的 S/EXP_INFO_S 时才设置 `_is_s_rank`,以免 SP 完成逻辑把非 S 的战斗误判为通过。
- `AutoSearchCombat` 上新增的 `_auto_search_emotion_reduce`、`_auto_search_fleet_index` 和 `_shipwreck_emotion_reduced` 标志是类属性,会在实例之间共享;如果自动周回流程可能并发运行或被复用,建议把这些改为实例属性,以避免不同运行之间的状态泄漏。
## 单条评论
### 评论 1
<location path="deploy/uv.py" line_range="185-188" />
<code_context>
def _managed_python_executable(root: Path) -> Optional[Path]:
install_dir = venv_python_install_dir(root)
- for python_home in sorted(install_dir.glob(f"cpython-{PYTHON_VERSION}-*")):
+ for python_home in sorted(install_dir.glob("cpython-*-*"), reverse=True):
candidates = [
python_home / "python.exe",
- python_home / "bin" / "python3.14",
+ python_home / "bin" / "python3",
python_home / "bin" / "python",
]
</code_context>
<issue_to_address>
**suggestion (bug_risk):** 基于路径的反向排序方式可能无法稳定地选出版本最高的 cpython 目录
这个循环依赖对诸如 `cpython-3.10.5-*` 和 `cpython-3.9.18-*` 的名称进行字典序反向排序。根据具体命名(例如 `cpython-3.9.18-*` 与 `cpython-3.11.0-*`)或未来格式变更,字符串排序可能无法反映真实的版本顺序。如果目标是选择最新的解释器,建议从目录名中提取版本,并按 `(major, minor, patch)` 元组排序,而不是按原始字符串排序,以避免在存在多个安装时选到较旧的版本。
建议实现方式:
```python
DEPENDENCY_SYNC_TIMEOUT = 30 * 60
def _cpython_dir_version(path: Path) -> tuple[int, int, int]:
"""Extract a (major, minor, patch) tuple from a cpython install dir name.
Expected formats include:
- cpython-3.10.5-*
- cpython-3.11-*
Falls back to (0, 0, 0) if parsing fails so those entries are sorted last.
"""
name = path.name
# Expected name pattern: cpython-<version>-<suffix>
parts = name.split("-")
if len(parts) < 3 or parts[0] != "cpython":
return (0, 0, 0)
version_str = parts[1]
version_components = version_str.split(".")
# Normalize to (major, minor, patch) length
try:
major = int(version_components[0]) if len(version_components) > 0 else 0
minor = int(version_components[1]) if len(version_components) > 1 else 0
patch = int(version_components[2]) if len(version_components) > 2 else 0
except ValueError:
# Non-numeric version segment; treat as lowest priority
return (0, 0, 0)
return (major, minor, patch)
def _managed_python_executable(root: Path) -> Optional[Path]:
```
```python
install_dir = venv_python_install_dir(root)
python_homes = sorted(
install_dir.glob("cpython-*-*"),
key=_cpython_dir_version,
reverse=True,
)
for python_home in python_homes:
```
</issue_to_address>让我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈持续改进评审质量。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- In
CoalitionScuttleCombat,_is_s_rankis set whenis_auto_search_running()is true, which doesn’t actually guarantee an S-rank result; consider limiting_is_s_rankto confirmed S/EXP_INFO_S detections so SP completion logic doesn’t misclassify non‑S runs as passed. - The new
_auto_search_emotion_reduce,_auto_search_fleet_index, and_shipwreck_emotion_reducedflags onAutoSearchCombatare class attributes shared across instances; if multiple auto-search workflows can run concurrently or be reused, consider making these instance attributes to avoid cross-run state leakage.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `CoalitionScuttleCombat`, `_is_s_rank` is set when `is_auto_search_running()` is true, which doesn’t actually guarantee an S-rank result; consider limiting `_is_s_rank` to confirmed S/EXP_INFO_S detections so SP completion logic doesn’t misclassify non‑S runs as passed.
- The new `_auto_search_emotion_reduce`, `_auto_search_fleet_index`, and `_shipwreck_emotion_reduced` flags on `AutoSearchCombat` are class attributes shared across instances; if multiple auto-search workflows can run concurrently or be reused, consider making these instance attributes to avoid cross-run state leakage.
## Individual Comments
### Comment 1
<location path="deploy/uv.py" line_range="185-188" />
<code_context>
def _managed_python_executable(root: Path) -> Optional[Path]:
install_dir = venv_python_install_dir(root)
- for python_home in sorted(install_dir.glob(f"cpython-{PYTHON_VERSION}-*")):
+ for python_home in sorted(install_dir.glob("cpython-*-*"), reverse=True):
candidates = [
python_home / "python.exe",
- python_home / "bin" / "python3.14",
+ python_home / "bin" / "python3",
python_home / "bin" / "python",
]
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Path-based reverse sorting of cpython dirs may not pick the highest version consistently
This loop relies on reverse lexicographic ordering of names like `cpython-3.10.5-*` and `cpython-3.9.18-*`. Depending on the exact naming (e.g. `cpython-3.9.18-*` vs `cpython-3.11.0-*`) or future format changes, string ordering may not reflect actual version ordering. If the goal is to pick the newest interpreter, consider extracting the version from the directory name and sorting by a `(major, minor, patch)` tuple rather than the raw string to avoid selecting an older version when multiple installs exist.
Suggested implementation:
```python
DEPENDENCY_SYNC_TIMEOUT = 30 * 60
def _cpython_dir_version(path: Path) -> tuple[int, int, int]:
"""Extract a (major, minor, patch) tuple from a cpython install dir name.
Expected formats include:
- cpython-3.10.5-*
- cpython-3.11-*
Falls back to (0, 0, 0) if parsing fails so those entries are sorted last.
"""
name = path.name
# Expected name pattern: cpython-<version>-<suffix>
parts = name.split("-")
if len(parts) < 3 or parts[0] != "cpython":
return (0, 0, 0)
version_str = parts[1]
version_components = version_str.split(".")
# Normalize to (major, minor, patch) length
try:
major = int(version_components[0]) if len(version_components) > 0 else 0
minor = int(version_components[1]) if len(version_components) > 1 else 0
patch = int(version_components[2]) if len(version_components) > 2 else 0
except ValueError:
# Non-numeric version segment; treat as lowest priority
return (0, 0, 0)
return (major, minor, patch)
def _managed_python_executable(root: Path) -> Optional[Path]:
```
```python
install_dir = venv_python_install_dir(root)
python_homes = sorted(
install_dir.glob("cpython-*-*"),
key=_cpython_dir_version,
reverse=True,
)
for python_home in python_homes:
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| for python_home in sorted(install_dir.glob("cpython-*-*"), reverse=True): | ||
| candidates = [ | ||
| python_home / "python.exe", | ||
| python_home / "bin" / "python3.14", | ||
| python_home / "bin" / "python3", |
There was a problem hiding this comment.
suggestion (bug_risk): 基于路径的反向排序方式可能无法稳定地选出版本最高的 cpython 目录
这个循环依赖对诸如 cpython-3.10.5-* 和 cpython-3.9.18-* 的名称进行字典序反向排序。根据具体命名(例如 cpython-3.9.18-* 与 cpython-3.11.0-*)或未来格式变更,字符串排序可能无法反映真实的版本顺序。如果目标是选择最新的解释器,建议从目录名中提取版本,并按 (major, minor, patch) 元组排序,而不是按原始字符串排序,以避免在存在多个安装时选到较旧的版本。
建议实现方式:
DEPENDENCY_SYNC_TIMEOUT = 30 * 60
def _cpython_dir_version(path: Path) -> tuple[int, int, int]:
"""Extract a (major, minor, patch) tuple from a cpython install dir name.
Expected formats include:
- cpython-3.10.5-*
- cpython-3.11-*
Falls back to (0, 0, 0) if parsing fails so those entries are sorted last.
"""
name = path.name
# Expected name pattern: cpython-<version>-<suffix>
parts = name.split("-")
if len(parts) < 3 or parts[0] != "cpython":
return (0, 0, 0)
version_str = parts[1]
version_components = version_str.split(".")
# Normalize to (major, minor, patch) length
try:
major = int(version_components[0]) if len(version_components) > 0 else 0
minor = int(version_components[1]) if len(version_components) > 1 else 0
patch = int(version_components[2]) if len(version_components) > 2 else 0
except ValueError:
# Non-numeric version segment; treat as lowest priority
return (0, 0, 0)
return (major, minor, patch)
def _managed_python_executable(root: Path) -> Optional[Path]: install_dir = venv_python_install_dir(root)
python_homes = sorted(
install_dir.glob("cpython-*-*"),
key=_cpython_dir_version,
reverse=True,
)
for python_home in python_homes:Original comment in English
suggestion (bug_risk): Path-based reverse sorting of cpython dirs may not pick the highest version consistently
This loop relies on reverse lexicographic ordering of names like cpython-3.10.5-* and cpython-3.9.18-*. Depending on the exact naming (e.g. cpython-3.9.18-* vs cpython-3.11.0-*) or future format changes, string ordering may not reflect actual version ordering. If the goal is to pick the newest interpreter, consider extracting the version from the directory name and sorting by a (major, minor, patch) tuple rather than the raw string to avoid selecting an older version when multiple installs exist.
Suggested implementation:
DEPENDENCY_SYNC_TIMEOUT = 30 * 60
def _cpython_dir_version(path: Path) -> tuple[int, int, int]:
"""Extract a (major, minor, patch) tuple from a cpython install dir name.
Expected formats include:
- cpython-3.10.5-*
- cpython-3.11-*
Falls back to (0, 0, 0) if parsing fails so those entries are sorted last.
"""
name = path.name
# Expected name pattern: cpython-<version>-<suffix>
parts = name.split("-")
if len(parts) < 3 or parts[0] != "cpython":
return (0, 0, 0)
version_str = parts[1]
version_components = version_str.split(".")
# Normalize to (major, minor, patch) length
try:
major = int(version_components[0]) if len(version_components) > 0 else 0
minor = int(version_components[1]) if len(version_components) > 1 else 0
patch = int(version_components[2]) if len(version_components) > 2 else 0
except ValueError:
# Non-numeric version segment; treat as lowest priority
return (0, 0, 0)
return (major, minor, patch)
def _managed_python_executable(root: Path) -> Optional[Path]: install_dir = venv_python_install_dir(root)
python_homes = sorted(
install_dir.glob("cpython-*-*"),
key=_cpython_dir_version,
reverse=True,
)
for python_home in python_homes:
Summary by Sourcery
调整自动搜查战斗流程和 Python 环境管理,以提升减轻情绪值的准确性,并放宽对受管 Python 版本的限制。
Bug 修复:
增强:
构建:
Original summary in English
Summary by Sourcery
Adjust auto-search combat flow and Python environment management to improve emotion reduction accuracy and loosen managed Python version constraints.
Bug Fixes:
Enhancements:
Build: